﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using YasharEl.Infrastructure.ResourcesManagement;

namespace YasharEl.Infrastructure.ProcessEngine
{
    [Serializable]
    public class ProcessDefinitionAccessDeniedException : TranslatedDomainModelException
    {
        private const string ProcessDefinitionAccessDenied = "ProcessDefinitionAccessDenied";

        private readonly long _applicationId;
        private readonly long _processDefinitionId;

        public long GivenApplicationId
        {
            get { return _applicationId; }
        }

        public long RequestedProcessDefinitionId
        {
            get
            {
                return _processDefinitionId;
            }
        }

        public ProcessDefinitionAccessDeniedException(IResourceManager resourceManager, long applicationId, long processDefinitionId)
            : base
             (
                resourceManager,
                string.Format(
                    resourceManager.GetString(ProcessDefinitionAccessDenied, CultureInfo.GetCultureInfo("en")),
                    applicationId,
                    processDefinitionId
                )
             )
        {
            _applicationId = applicationId;
            _processDefinitionId = processDefinitionId;
        }

        protected ProcessDefinitionAccessDeniedException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }


        protected override string ExceptionMessageResourceKey
        {
            get { return ProcessDefinitionAccessDenied; }
        }

        public override string TranslatedMessage
        {
            get
            {
                return string.Format(resourceManager.GetString(ExceptionMessageResourceKey), GivenApplicationId, RequestedProcessDefinitionId);
            }
        }
    }
}
